#include <func.h>

void* thread_func(void* p)
{
    while(1)
    {
        //用于检查当前线程是否收到了取消请求。
        pthread_testcancel();
    }
    return  NULL;
}

int main()
{
    pthread_t th_id;
    int ret=pthread_create(&th_id,NULL,thread_func,NULL);
    THREAD_ERR_CHECK(ret,"pthread_creat");
    printf("I am main thread\n");

    ret=pthread_cancel(th_id);
    THREAD_ERR_CHECK(ret,"pthread_cancle");
    long thread_ret;
    ret=pthread_join(th_id,(void**)&thread_ret);
    THREAD_ERR_CHECK(ret,"pthread_join");
    printf("I am main thread %ld\n",thread_ret);
    return 0;
}